home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /*________________________________________________________________________
- |
- | transparent.c - simulate transparancy by using writemask patterns
- |
- | I use patterns, instead of real alpha, because it works on every
- | machine, and on entry level graphics it's much faster.
- |
- | (c) Frans van Hoesel 1994, Xtreme Graphics Software
- |
- */
-
- #include <gl/gl.h>
- #include "transparent.h"
-
-
- /*__________________________________________________________________________
- |
- | set_alpha - change apparent transparancy
- |
- | the argument alph should be between 0 and 1
- */
-
- void set_alpha(float alph) {
- int pat;
- pat = (int)(alph*16+0.5);
- if (pat > 16)
- pat = 16;
- setpattern(pat);
- }
-
- void init_alpha(void) {
-
- unsigned short mask[16];
-
- mask[0] = mask[4] = mask[8] = mask[12] = 0xffff;
- mask[1] = mask[5] = mask[9] = mask[13] = 0xffff;
- mask[2] = mask[6] = mask[10] = mask[14] = 0xffff;
- mask[3] = mask[7] = mask[11] = mask[15] = 0xeeee;
- defpattern(1, 16, mask);
- mask[1] = mask[5] = mask[9] = mask[13] = 0xbbbb;
- defpattern(2, 16, mask);
- mask[3] = mask[7] = mask[11] = mask[15] = 0xaaaa;
- defpattern(3, 16, mask);
- mask[1] = mask[5] = mask[9] = mask[13] = 0xaaaa;
- defpattern(4, 16, mask);
- mask[2] = mask[6] = mask[10] = mask[14] = 0xdddd;
- defpattern(5, 16, mask);
- mask[0] = mask[4] = mask[8] = mask[12] = 0x7777;
- defpattern(6, 16, mask);
- mask[2] = mask[6] = mask[10] = mask[14] = 0x5555;
- defpattern(7, 16, mask);
- mask[0] = mask[4] = mask[8] = mask[12] = 0x5555;
- defpattern(8, 16, mask);
- mask[3] = mask[7] = mask[11] = mask[15] = 0x8888;
- defpattern(9, 16, mask);
- mask[1] = mask[5] = mask[9] = mask[13] = 0x2222;
- defpattern(10, 16, mask);
- mask[3] = mask[7] = mask[11] = mask[15] = 0x0;
- defpattern(11, 16, mask);
- mask[1] = mask[5] = mask[9] = mask[13] = 0x0;
- defpattern(12, 16, mask);
- mask[2] = mask[6] = mask[10] = mask[14] = 0x4444;
- defpattern(13, 16, mask);
- mask[0] = mask[4] = mask[8] = mask[12] = 0x1111;
- defpattern(14, 16, mask);
- mask[2] = mask[6] = mask[10] = mask[14] = 0x0;
- defpattern(15, 16, mask);
- mask[0] = mask[4] = mask[8] = mask[12] = 0x0;
- defpattern(16, 16, mask);
- setpattern(0);
- }
-